using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Serialization;

namespace CentralOffice.WebClient.CommonServices
{
    /// <summary>
    /// Summary description for $codebehindclassname$
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class DemoHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            int seed = Int32.Parse(context.Request.QueryString["seed"]);
            int lower = Int32.Parse(context.Request.QueryString["lower"]);
            int upper = Int32.Parse(context.Request.QueryString["upper"]);

            //long tick = DateTime.Now.Ticks;
            //Random randObj = new Random((int)(seed & 0xffffffffL) | (int)(tick >> 32));

            //Random randObj = new Random(seed);
            string[] ss = new string[100];
            for (int j = 0; j < 100; j++)
            {
                Random randObj = new Random(unchecked((int)DateTime.Now.Ticks));

                ss[j] = randObj.Next(lower, upper).ToString();
            }
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
            context.Response.Write(javaScriptSerializer.Serialize(ss));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
